﻿Public Class FormSettings
    Dim WindowerDisplay As New WindowerFFXI.Display
    Private Sub btnOK_Click(sender As System.Object, e As System.EventArgs) Handles btnOK.Click
        My.Settings.PlayerRandom = chkRandom.Checked
        My.Settings.PlayerLoop = chkRepeat.Checked

        My.Settings.WindowerX = Convert.ToInt32(txtX.Text)
        My.Settings.WindowerY = Convert.ToInt32(txtY.Text)

        If cboDisplay.Text = "Single Line" Then
            My.Settings.WindowerDisplay = "single"
        ElseIf cboDisplay.Text = "Multiline" Then
            My.Settings.WindowerDisplay = "multi"
        End If

        If chkTopMost.Checked = True Then
            FormMain.TopMost = True
            My.Settings.topmost = True
        Else
            FormMain.TopMost = False
            My.Settings.topmost = False
        End If
        My.Settings.Save()
        FormMain.UpdatePlayer()
        If displayupdate = True Then UpdateDisplay()
    End Sub

    Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub FormSettings_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        chkRandom.Checked = My.Settings.PlayerRandom
        chkRepeat.Checked = My.Settings.PlayerLoop
        txtX.Text = My.Settings.WindowerX
        txtY.Text = My.Settings.WindowerY
        If My.Settings.WindowerDisplay = "single" Then
            cboDisplay.SelectedIndex = 0
        ElseIf My.Settings.WindowerDisplay = "multi" Then
            cboDisplay.SelectedIndex = 1
        End If
        chkTopMost.Checked = My.Settings.Topmost

        cboClient.SelectedIndex = My.Settings.PlayerClient
        cboClient.Enabled = False
        If FormMain.TopMost = True Then Me.TopMost = True
    End Sub

    Private Sub chkRandom_CheckStateChanged(sender As Object, e As System.EventArgs) Handles chkRandom.CheckStateChanged
        My.Settings.PlayerRandom = chkRandom.Checked
    End Sub

    Private Sub chkRepeat_CheckStateChanged(sender As Object, e As System.EventArgs) Handles chkRepeat.CheckStateChanged
        My.Settings.PlayerLoop = chkRepeat.Checked
    End Sub

    Private Sub txtX_TextChanged(sender As Object, e As System.EventArgs) Handles txtX.TextChanged
        My.Settings.WindowerX = Convert.ToInt32(txtX.Text)
    End Sub

    Private Sub txtY_TextChanged(sender As Object, e As System.EventArgs) Handles txtY.TextChanged
        My.Settings.WindowerY = Convert.ToInt32(txtY.Text)
    End Sub

    Private Sub cboDisplay_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboDisplay.SelectedIndexChanged
        If cboDisplay.Text = "Single Line" Then
            My.Settings.WindowerDisplay = "single"
        ElseIf cboDisplay.Text = "Multiline" Then
            My.Settings.WindowerDisplay = "multi"
        End If
    End Sub

    Private Sub chkArtist_CheckStateChanged(sender As Object, e As System.EventArgs) Handles chkArtist.CheckStateChanged
        My.Settings.ShowArtist = chkArtist.Checked
    End Sub

    Private Sub chkDuration_CheckStateChanged(sender As Object, e As System.EventArgs) Handles chkDuration.CheckStateChanged
        My.Settings.ShowDuration = chkDuration.Checked
    End Sub

    Private Sub chkTitle_CheckStateChanged(sender As Object, e As System.EventArgs) Handles chkTitle.CheckStateChanged
        My.Settings.ShowTitle = chkTitle.Checked
    End Sub

    Private Sub cboClient_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles cboClient.SelectedIndexChanged
        My.Settings.PlayerClient = cboClient.SelectedIndex
    End Sub
End Class